/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       postprocess.h
 * Author:     twoja stara
 * Created on: 2009-09-17
 *
 **********************************************************************************************************************/

#ifndef POSTPROCESS_H_
#define POSTPROCESS_H_

#include "gpuprogram.h"
#include "texture.h"
#include "rendertarget.h"

namespace mGameEngine
{
namespace Graphics
{

/**
 * Image post-processing interface.
 * Last stage of rendering output image.
 */
class PostProcess
{
protected:
    /**
     * Input texture.
     */
    const Texture *_input;

    /**
     * Output render target.
     */
    RenderTarget *_output;

    /**
     * Is post process enabled.
     */
    bool _enabled;

    /**
     * Pass unprocessed input image to render target.
     */
    void _passUnprocessed() const;

public:
    /**
     * Create post-process with specified input and output.
     * @param input input texture.
     * @param output output render target.
     */
    PostProcess(const Texture *input = NULL, RenderTarget *output = NULL);

    /**
     * Destroy post-process.
     */
    virtual ~PostProcess();

    /**
     * Get post-process input texture.
     * @return post-process input texture.
     */
    const Texture *getInput() const
    {
        return _input;
    }

    /**
     * Set post-procces input texture.
     * @param input input textre.
     */
    void setInput(const Texture *input)
    {
        _input = input;
    }

    /**
     * Get post-process output render target.
     * @return post-process output render target.
     */
    RenderTarget *getOutput() const
    {
        return _output;
    }

    /**
     * Set post process output render target.
     * @param output render target.
     */
    void setOutput(RenderTarget *output)
    {
        _output = output;
    }

    /**
     * Check if post process is enabled.
     * @return true if post process is enabled, false otherwise.
     */
    bool isEnabled() const
    {
        return _enabled;
    }

    /**
     * Enable/disable post process.
     * @param enabled true to enable post process, false to disable.
     */
    void setEnabled(bool enabled)
    {
        _enabled = enabled;
    }

    /**
     * Toggle post process.
     */
    void toggleEnabled()
    {
        _enabled = !_enabled;
    }

    /**
     * Process input image and render output to render target.
     */
    virtual void process() const = 0;
};

}
}

#endif // POSTPROCESS_H_
